<?php
require_once 'DBClass.php';
$current_time=time();

//Delete data from ndtl_list table.
$db->sql_query('delete from ndtl_list');

//Delete data from ndtl_task tabe.
$db->sql_query('delete from ndtl_task');

//Insert data to ndtl_list table
$list_data = array('專案01','專案02');
$insert_list_sql="insert into ndtl_list (name,created_date) values (:name,:time)";
$sql_stmt=$db->sql_prepare($insert_list_sql);

foreach($list_data as $data){
	$sql_stmt->bindValue('name',$data,SQLITE3_TEXT);
	$sql_stmt->bindValue('time',$current_time,SQLITE3_INTEGER);
	$sql_stmt->execute();
}
//Insert data to ndtl_task table
$task_data = array(
array('id'=>1,'name'=>'不可能的任務'),
array('id'=>2,'name'=>'又上演第二集')
);
$insert_task_sql="insert into ndtl_task (list_id,name,created_date) values (:id,:name,:time)";
$sql_stmt = $db->sql_prepare($insert_task_sql);

foreach($task_data as $data){
	$sql_stmt->bindValue('id',$data['id'],SQLITE3_INTEGER);
	$sql_stmt->bindValue('name',$data['name'],SQLITE3_TEXT);
	$sql_stmt->bindValue('time',$current_time,SQLITE3_INTEGER);
	$sql_stmt->execute();
}
?>